受注管理画面のステータス管理でステータスを変更後、まとめてポイント付与できるようにしてみました。
テスト環境のXAMPPでは動作しております。本日、下記の本番環境でテストしてみます。
環境
OS:CentOS4.6
EC-CUBEバージョン:2.0.1
PHPバージョン:5.1.6
DB:MySQL 4.1.20
dtb_customerにフィールド追加。
フィールド名:total_point
注文完了時にすぐにポイントが付与されないようにLC_Page_Shopping_Complete.phpを変更。
引用:
/* 購入情報を会員テーブルに登録する */
function lfSetCustomerPurchase($customer_id, $arrData, &$objQuery) {
$col = "first_buy_date, last_buy_date, buy_times, buy_total, point";
$where = "customer_id = ?";
$arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
$sqlval = $arrRet[0];
if($sqlval['first_buy_date'] == "") {
$sqlval['first_buy_date'] = "Now()";
}
$sqlval['last_buy_date'] = "Now()";
$sqlval['buy_times']++;
$sqlval['buy_total']+= $arrData['total'];
$sqlval['point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
// ポイントが不足している場合
if($sqlval['point'] < 0) {
$objQuery->rollback();
SC_Utils_Ex::sfDispSiteError(LACK_POINT);
}
$objQuery->update("dtb_customer", $sqlval, $where, array($customer_id));
}
上記を下記に変更。
引用:
/* 購入情報を会員テーブルに登録する */
function lfSetCustomerPurchase($customer_id, $arrData, &$objQuery) {
$col = "first_buy_date, last_buy_date, buy_times, buy_total, point";
$where = "customer_id = ?";
$arrRet = $objQuery->select($col, "dtb_customer", $where, array($customer_id));
$sqlval = $arrRet[0];
if($sqlval['first_buy_date'] == "") {
$sqlval['first_buy_date'] = "Now()";
}
$sqlval['last_buy_date'] = "Now()";
$sqlval['buy_times']++;
$sqlval['buy_total']+= $arrData['total'];
$sqlval['total_point'] = ($sqlval['point'] + $arrData['add_point'] - $arrData['use_point']);
$sqlval['point'] = ($sqlval['point'] - $arrData['use_point']);
// ポイントが不足している場合
if($sqlval['point'] < 0) {
$objQuery->rollback();
SC_Utils_Ex::sfDispSiteError(LACK_POINT);
}
$objQuery->update("dtb_customer", $sqlval, $where, array($customer_id));
}
ステータス管理画面でステータスを発送済みなどに変更すればポイントを付与するためにLC_Page_Admin_Order_Status.phpを変更。
引用:
//ステータス情報の更新(削除)
function lfStatusMove($status_id, $arrMove){
$objQuery = new SC_Query();
$masterData = new SC_DB_MasterData_Ex();
$arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
$table = 'dtb_order';
$where = 'order_id = ?';
$arrUpdate = array('update_date' => 'NOW()');
$delflg = '1'; // 削除フラグ
$message = ''; // ステータス変更後にポップアップするメッセージの内容
if ( $status_id == 'delete' ) {
$arrUpdate['del_flg'] = $delflg;
$message = '削除';
}
// ステータスが発送済みの時は発送日を更新
elseif ( $status_id == ORDER_DELIV ) {
$arrUpdate['status'] = $status_id;
$arrUpdate['commit_date'] = 'NOW()';
$message = $arrORDERSTATUS[$status_id] . 'へ移動';
}
else {
$arrUpdate['status'] = $status_id;
$message = $arrORDERSTATUS[$status_id] . 'へ移動';
}
if ( isset($arrMove) ){
foreach ( $arrMove as $val ){
if ( $val != "" ) {
$objQuery->update($table, $arrUpdate, $where, array($val));
}
}
}
$this->tpl_onload = "window.alert('選択項目を" . $message . "しました。');";
}
上記を下記に変更。
引用:
//ステータス情報の更新(削除)
function lfStatusMove($status_id, $arrMove){
$objQuery = new SC_Query();
$masterData = new SC_DB_MasterData_Ex();
$arrORDERSTATUS = $masterData->getMasterData("mtb_order_status");
$table = 'dtb_order';
$where = 'order_id = ?';
$arrUpdate = array('update_date' => 'NOW()');
$delflg = '1'; // 削除フラグ
$message = ''; // ステータス変更後にポップアップするメッセージの内容
if ( $status_id == 'delete' ) {
$arrUpdate['del_flg'] = $delflg;
$message = '削除';
}
// ステータスが発送済みの時は発送日を更新
elseif ( $status_id == ORDER_DELIV ) {
$arrUpdate['status'] = $status_id;
$arrUpdate['commit_date'] = 'NOW()';
$message = $arrORDERSTATUS[$status_id] . 'へ移動';
}
else {
$arrUpdate['status'] = $status_id;
$message = $arrORDERSTATUS[$status_id] . 'へ移動';
}
if ( isset($arrMove) ){
foreach ( $arrMove as $val ){
if ( $val != "" ) {
$arrRet = $objQuery->select("customer_id", $table, $where, array($val));
$customer_id = $arrRet[0]['customer_id'];
if($customer_id != "" && $customer_id >= 1) {
$arrRet = $objQuery->select('total_point', 'dtb_customer', 'customer_id = ?', array($customer_id));
$sqlval['point'] = $arrRet[0]['total_point'];
$objQuery->update('dtb_customer', $sqlval, 'customer_id = ?', array($customer_id));
}
$objQuery->update($table, $arrUpdate, $where, array($val));
}
}
}
$this->tpl_onload = "window.alert('選択項目を" . $message . "しました。');";
}
注文完了後にすぐにポイントは付与されません。ステータス管理画面でステータスを発送済みなどに変更すれば、ポイントが付与されます。1件1件ではなく、まとめてステータスを移動した注文分にポイント付与されます。
当方の場合、発送後にすぐにステータスを発送済みにするのではなく、注文日より8日後にステータスを発送済みに変更しポイントを付与しようと考えています。
ステータスは発送済み以外でもポイント付与されますので、発送済みの時だけポイント付与できるように今後してみます。