ecshop开发日志之手机端虚拟商品自动发货
在ecshop官方模版收,web端的虚拟商品购买后不能像pc端那般直接在付款后出现虚拟商品的卡号,密码,截止日期
一下为让手机购买也可以在付款后自动显示发货并能显示卡号密码截止日期
首
先找到pc端的flow.php文件中的$_REQUEST['act'] = 'done'
这里面是用来处理订单的最后一步,(具体怎么知道的可以看url后的参数列表),对应手机端处理订单的的文件为 mobile/order.php
文件,这里同样有一个$_REQUEST['act'] = 'done',对比里面的代码发现order.php相比flow.php
缺少了一段处理虚拟商品的代码找到ecshop官方的flow.php文件中大约1677行有一个注释
/*/* 如果使用库存,且下订单时减库存,则减少库存 */*/下面的if判断语句还是相同
这句话上面还有一段代码(如下),在手机端不存在,具体功能(追到函数里这段是说:设置红包已经使用,和我们现在需求的功能无关)
if ($order['bonus_id'] > 0 && $temp_amout > 0)
{
use_bonus($order['bonus_id'], $new_order_id);
}
下面还有两端代码是手机端没有的
/* 给商家发邮件 ----- 这段或许可以不要,我没有测试 */
/* 增加是否给客服发送邮件选项 */
if ($_CFG['send_service_email'] && $_CFG['service_email'] != '')
{
$tpl = get_mail_template('remind_of_new_order');
$smarty->assign('order', $order);
$smarty->assign('goods_list', $cart_goods);
$smarty->assign('shop_name', $_CFG['shop_name']);
$smarty->assign('send_date', date($_CFG['time_format']));
$content = $smarty->fetch('str:' . $tpl['template_content']);
send_mail($_CFG['shop_name'], $_CFG['service_email'], $tpl['template_subject'], $content, $tpl['is_html']);
} /* 如果需要,发短信 ----- 这段也是没有的,应该也不需要*/
if ($_CFG['sms_order_placed'] == '1' && $_CFG['sms_shop_mobile'] != '')
{
include_once('includes/cls_sms.php');
$sms = new sms();
$msg = $order['pay_status'] == PS_UNPAYED ?
$_LANG['order_placed_sms'] : $_LANG['order_placed_sms'] . '[' . $_LANG['sms_paid'] . ']';
$sms->send($_CFG['sms_shop_mobile'], sprintf($msg, $order['consignee'], $order['tel']),'', 13,1);
}
下面的关键的代码 ----- 是关系到我们现在的功能是不是能用
virtual_goods_ship($virtual_goods,$msg,
$order['order_sn'],
true)这个函数里面会有一个smarty的assign方法就是这里将虚拟商品的卡号密码等信息发送到页面中,并处理发货状态等,有兴趣的童鞋可以进
去看看,
/* 如果订单金额为0 处理虚拟卡 */
if ($order['order_amount'] <= 0)
{
$sql = "SELECT goods_id, goods_name, goods_number AS num FROM ".
$GLOBALS['ecs']->table('cart') .
" WHERE is_real = 0 AND extension_code = 'virtual_card'".
" AND session_id = '".SESS_ID."' AND rec_type = '$flow_type'"; $res = $GLOBALS['db']->getAll($sql); $virtual_goods = array();
foreach ($res AS $row)
{
$virtual_goods['virtual_card'][] = array('goods_id' => $row['goods_id'], 'goods_name' => $row['goods_name'], 'num' => $row['num']);
} if ($virtual_goods AND $flow_type != CART_GROUP_BUY_GOODS)
{
/* 虚拟卡发货 */
if (virtual_goods_ship($virtual_goods,$msg, $order['order_sn'], true))
{
/* 如果没有实体商品,修改发货状态,送积分和红包 */
$sql = "SELECT COUNT(*)" .
" FROM " . $ecs->table('order_goods') .
" WHERE order_id = '$order[order_id]' " .
" AND is_real = 1";
if ($db->getOne($sql) <= 0)
{
/* 修改订单状态 */
update_order($order['order_id'], array('shipping_status' => SS_SHIPPED, 'shipping_time' => gmtime())); /* 如果订单用户不为空,计算积分,并发给用户;发红包 */
if ($order['user_id'] > 0)
{
/* 取得用户信息 */
$user = user_info($order['user_id']); /* 计算并发放积分 */
$integral = integral_to_give($order);
log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($_LANG['order_gift_integral'], $order['order_sn'])); /* 发放红包 */
send_order_bonus($order['order_id']);
}
}
}
}
}
这里的代码添加上以后变量已经发送到页面中了,在手机模版收是order_done.dwt文件来显示最后一步的,这里和pc端的flow.dwt里全是判断的思路不太一样,找到flow.dwt文件中显示虚拟商品信息的那段代码如下(其实可以自己找找)
<!--{if $virtual_card}-->
<div style="text-align:center;overflow:hidden;border:1px solid #E2C822;background:#FFF9D7;margin:10px;padding:10px 50px 30px;">
<!--{foreach from=$virtual_card item=vgoods}-->
<h3 style="color:#2359B1; font-size:12px;">{$vgoods.goods_name}</h3>
<!--{foreach from=$vgoods.info item=card}-->
<ul style="list-style:none;padding:0;margin:0;clear:both">
<!--{if $card.card_sn}-->
<li style="margin-right:50px;float:left;"> <strong>卡号:</strong><span style="color:red;">{$card.card_sn}</span> </li>
<!--{/if}-->
<!--{if $card.card_password}-->
<li style="margin-right:50px;float:left;"> <strong>密码:</strong><span style="color:red;">{$card.card_password}</span> </li>
<!--{/if}-->
<!--{if $card.end_date}-->
<li style="float:left;"> <strong>截止日期:</strong>{$card.end_date} </li>
<!--{/if}-->
</ul>
<!--{/foreach}-->
<!--{/foreach}-->
</div>
<!--{/if}-->
放到order_done.dwt里一个合适的位置,到此这个功能大概就完成了
但是我目前为止没有的是支付宝付款是不是能自动的返回这些卡号密码,我都是用余额支付的,如有不正确的地方,请不吝指正
ecshop开发日志之手机端虚拟商品自动发货的更多相关文章
- ecshop开发日志之虚拟商品发送邮件通知
购买虚拟商品,系统会在支付后自动发送邮件到用户填写的邮件地址中,追踪过程如下首先在订单列表中可以获得到处理订单的php文件为flow.php,之后在最后一步url地址显示为http://localho ...
- ECSHOP农行支付接口开发(含手机端)
对于ECSHOP来说,支付是以接口的形式存在的.于是: 1:首先添加接口文件 includes\modules\payment下,增加abcbank.php,代码如下: <?php /** * ...
- delphi xe5 android 开发数据访问手机端(一)
上几片文章我们把供手机端调用的web服务完成,接下来实现手机端调用webservices获取数据 1.新建firemonkey mobile application 2.选择blank applica ...
- ecshop开发日志之支付插件开发
ecshop开发一个支付插件的方法(例如要新建一个为paytest-----支付测试)1.languages/zh_cn/payment/目录下新建一个paytest.php文件 内容如下: < ...
- XE5 Android 开发数据访问手机端[转]
把供手机端调用的web服务完成,接下来实现手机端调用webservices获取数据 1.新建firemonkey mobile application 2.选择blank application 3. ...
- XE5 Android 开发数据访问手机端 解决乱码的办法
经过测试,将sqlserver里的字段由varchar 或者char 改为 nvarchar 或者nchar 然后在手机端的clientdataset 增加字段的时候数据类型选择widestrin ...
- delphi xe5 android 开发数据访问手机端 解决乱码的办法
经过测试,将sqlserver里的字段由varchar 或者char 改为 nvarchar 或者nchar 然后在手机端的clientdataset 增加字段的时候数据类型选择widestrin ...
- XE5 Android 开发数据访问手机端 解决乱码的办法 [转]
经过测试,将sqlserver里的字段由varchar 或者char 改为 nvarchar 或者nchar 然后在手机端的clientdataset 增加字段的时候数据类型选择widestrin ...
- delphi xe5 android 开发数据访问手机端(二)
界面就这样吧,继续...,先启动咱们上几片文章建立的手机服务端 导入webservices单元,file->new->other->webservices->选择 wsdlim ...
随机推荐
- 【LeetCode】【Python】Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using ex ...
- 《think in python》学习-8
字符串 字符串是一个序列,可以用方括号操作符来访问字符串中的单独字符 fruit = 'banana' letter = fruit[1] 方括号中的表达式称为下标 下标从0 开始 任何表达式,包括变 ...
- 自定义不等高的cell-(storyboard)
对比自定义等高cell,需要几个额外的步骤(iOS8开始才支持) 添加子控件和contentView之间的间距约束 设置tableViewCell的真实行高和估算行高 // 告诉tableView所有 ...
- zookeeper_03:Java 客户端(原生API)
环境配置 下载并ZooKeeper的发行版 新建Java project,并导入jar包 创建会话 public class CreateSession implements Watcher { pr ...
- Best Time to Buy and Sell Stock I && II
Say you have an array for which the ith element is the price of a given stock on day i. If you were ...
- shell ps1 提示设置
PS1="\[\033[01;37m\]\u\[\033[00m\]@\[\033[01;31m\]localhost \t\[\033[00m\]:\[\033[01;35m\]\w\[\ ...
- JUnit报空指针错误,控制台不报任何错误
解决方法:1. 在测试类的beforeClass方法上加try-catch块 2. 添加main方法,里面添加beforeClass();
- PHP发红包程序
//红包算法$total = 20; //红包总金额$num = 10; //红包个数$min = 0.01; //每个人最少能收到0.01 for ($i=1;$i<$num; ...
- Thinkphp3.2使用scws中文分词 提取关键词
SCWS 是 Simple Chinese Word Segmentation 的首字母缩写(即:简易中文分词系统).1.下载scws官方提供的类(这里使用的是pscws第四版的)http://www ...
- 如何使用getopt()函数解析参数
最近在写程序的过程中,把一部分时间都花费在程序对参数的处理上.今天听了学长说到getopt函数,才发现原来c里面还有一个专门解决参数处理的函数,查询了相关资料,这里简单总结一下. 使用int main ...